<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频播放页面</title>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
        .video-background {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            object-fit: cover;
            display: none; /* 默认不显示视频 */
        }
        .video-container {
            position: relative;
            width: 80%;
            max-width: 800px;
            text-align: center;
            background-color: rgba(255, 255, 255, 0.8);
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            z-index: 1;
        }
        .video-container button {
            margin-top: 10px;
            padding: 10px 20px;
            font-size: 16px;
            color: #fff;
            background-color: #007bff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .video-container button:hover {
            background-color: #0056b3;
        }
        .video-container p {
            font-size: 20px;
            color: #333;
        }
        .background-image {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            background-image: url('/image/555.jpg'); /* 替换为您的静态图片路径 */
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }
    </style>
    <!-- 引入微信 JSSDK -->
    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
</head>
<body>
    <video class="video-background" loop id="backgroundVideo">
        <source src="/image/666.webm" type="video/webm">
        您的浏览器不支持视频播放。
    </video>
    <div class="background-image"></div> <!-- 备用静态图片 -->

    <div class="video-container">
        <button id="playButton">准备好冲了吗，等不了， 马上开始，准备好纸巾--点击这按钮</button>
        <p id="countdown">30</p>
    </div>

    <script>
        // 检测是否在微信浏览器中
        function isWeChatBrowser() {
            return /micromessenger/i.test(navigator.userAgent);
        }

        const countdownElement = document.getElementById('countdown');
        let countdown = 30;
        const playButton = document.getElementById('playButton');
        const backgroundVideo = document.getElementById('backgroundVideo');
        const backgroundImage = document.querySelector('.background-image');

        if (isWeChatBrowser()) {
            // 初始化微信 JSSDK
            wx.config({
                debug: false,
                appId: '',
                timestamp: '',
                nonceStr: '',
                signature: '',
                jsApiList: []
            });

            wx.ready(function () {
                // 微信环境准备好后尝试播放视频
                backgroundVideo.load();
                backgroundVideo.play();
                backgroundImage.style.display = 'none'; // 隐藏静态图片
                backgroundVideo.style.display = 'block'; // 显示视频
            });

            wx.error(function (res) {
                // 微信 JSSDK 初始化失败，显示静态图片
                backgroundImage.style.display = 'block';
            });
        } else {
            // 在其他浏览器中，尝试加载视频
            backgroundVideo.addEventListener('loadeddata', () => {
                backgroundImage.style.display = 'none'; // 隐藏静态图片
                backgroundVideo.style.display = 'block'; // 显示视频
                backgroundVideo.play(); // 播放视频
            });

            backgroundVideo.addEventListener('error', () => {
                backgroundImage.style.display = 'block'; // 显示静态图片
            });
        }

        // 倒计时函数
        const countdownInterval = setInterval(() => {
            countdownElement.textContent = countdown;
            countdown--;

            if (countdown < 0) {
                clearInterval(countdownInterval);
                countdownElement.textContent = "马上开始，准备好纸巾";
                if (!isWeChatBrowser()) {
                    backgroundVideo.play(); // 确保视频播放
                }
                setTimeout(() => {
                    window.location.href = "https://v.douyin.com/Rbju1SnTWzo/";
                }, 1000);
            }
        }, 1000);

        // 点击按钮直接跳转
        playButton.addEventListener('click', () => {
            clearInterval(countdownInterval);
            countdownElement.textContent = "马上开始，准备好纸巾";
            if (!isWeChatBrowser()) {
                backgroundVideo.play(); // 确保视频播放
            }
            window.location.href = "https://v.douyin.com/Rbju1SnTWzo/";
        });
    </script>
</body>
</html>